const { Layout , Menu } = antd;
const { Content, Sider,Footer,Header } = Layout;
const {HashRouter  , Route, Link } = ReactRouterDOM;
const NameConsumer=React.createContext("默认名称");
class App extends React.Component {
    render() {
        let name ="小人头sss"
        return (
            //Provider共享容器 接收一个name属性
            <NameConsumer.Provider value={name}>
                <div style={{border:'1px solid red',width:'30%',margin:'50px auto',textAlign:'center'}}>
                    <p>父组件定义的值:{name}</p>
                    <Son />
                </div>
            </NameConsumer.Provider>
        );
    }
}

class Son extends React.Component {
    consumerAction (context) {
        return (
            <div>
                <span>儿子:{context}</span>
            </div>
        )
    }
    render() {
        return (
            <NameConsumer.Consumer>
                {this.consumerAction}
           </NameConsumer.Consumer>
        
        );
    }
}
